/**
 * Created by yangfan on 2016/12/17.
 */
/**
 * Created by yangfan on 2016/9/2.
 */
define(['angular'],function(angular){
    angular.module("loginModule",[]).directive('loginModule',["$rootScope","$state",function($rootScope,$state){
       return {
           templateUrl:"app/business/common/login.html",
           link:function(scope,element,attrs){
               scope.logOut = function(){
                 scope.$emit("logOutEvent",{});
               };
               scope.goTo = function(){
                   if($rootScope.userLoginInfo.data.userType ==2){
                       $state.go("comIndexCtrl.sIndexCtrl");
                   }else{
                       $state.go("homepage");
                   }
               };
               scope.goLogin = function(state, m){
                   if(m == 1){
                       //login
                       $state.go("login",{type:"register"})
                   }
                   if(m == 0){
                       //register
                       $state.go("login",{type:"logion"})
                   }
               }
               scope.stateGo = function(state){
                   $state.go(state);
               }
           }
       }
    }]);
})
